﻿<?php  
$this->load->view('admin/pcategory/link_bar');
echo '<div class="title_function" style="clear:both">';
echo '<a class="adm_selected" href="'. base_url().'admin/pcategory/view/0">Danh mục gốc</a> :: ';
for($i=0; $i <count($track); $i++){
	echo "<a class='adm_selected' href='". base_url().'admin/pcategory/view/'. $track[$i]->id_pcategory."' >".$track[$i]->name." </a> :: ";
}
echo '</div>';
?>

		<form method="post" action="<?php base_url('admin/pcategory/delete')?>" class="form">
				
 <div class="box_function">
		<?php
        if(count($rows)){
        ?>
			<table width="747" border="0" cellpadding="0" cellspacing="0" class="listproduct" id="listproduct">
				<tbody>
				<tr>
					<td class="tilte_list_pro">
						<input name="checkme" class="noborder" onclick="checkDelBoxes(this.form, 'categoryBox[]', this.checked)" type="checkbox">
					</td>
					<td class="tilte_list_pro">
						<?php echo lang('image');?>
					</td>
                    <td class="tilte_list_pro">
						<?php echo lang('product_code');?>
					</td>
					<td class="tilte_list_pro">
						<?php echo lang('name');?>
					</td>
					<td class="tilte_list_pro">
						<?php echo lang('order_view');?>
					</td>
					<td class="tilte_list_pro">
						<?php echo lang('active');?>
					</td>
					<td class="tilte_list_pro">
						<?php echo lang('action');?>
					</td>
				</tr>
				
				<?php
				for($i = 0; $i < count($rows); $i++){
					$id = $rows[$i]->id_pcategory;
					$name = $rows[$i]->vi_name;
					$code = $rows[$i]->code;
					$description = $rows[$i]->vi_description;
					$parent = $id; //$rows[$i]->code;
					if($parent=='') $parent = '_';
					$active = $rows[$i]->active== 1 ? "checked.jpg" : "nocheck.jpg";
					
					$order_view = $rows[$i]->order_view;
					$min_position =  $rows[$i]->min_order;
					$max_position = $rows[$i]->max_order;
					//$num_child = 0; //$rows[$i]->num_child;
					$id_next = $rows[$i]->id_next;
					$id_preview = $rows[$i]->id_preview;
					$order_view = $rows[$i]->order_view;

                    if($i % 2 == 0) $css_class = 'row1';
                            else $css_class = 'row2';

                    $image = $rows[$i]->image;
                    if(!file_exists($image))
                        $image = "images/no_image.jpg";

					//$items .= eval ($this->loadTemplate('admin/pcategory/pcategory_item.tpl'));
				?>
				<tr class="<?php echo $css_class ?>">
					<td class="product">
						<input name="categoryBox[]" value="{$id}" class="noborder" type="checkbox"></td>
					<td class="pointer center" onclick="document.location = '#'">
					<img src="<?php echo base_url() . $image?>" height="50px" width="50px">
					</td>
                    <td class="pointer center" onclick="document.location = '#'">
					<?php echo $code?>
					</td>
					<td class="product" onclick="document.location = '#'">
					<a href="<?php echo site_url('admin/pcategory/view/'.$parent);?>">
                    <?php echo $name?>
                    </a>
					</td>
					<td class="product" onclick="document.location = '#'">
					<?php if($id_next/*$order_view < $max_position AND isset($rows[$i+1])*/){?>
						<a href="<?php echo site_url('admin/pcategory/change_order/' . $id.'/'.$id_next)?>">
							<img src="<?php echo base_url()?>images/admin/down.gif" alt="Up" title="Up" border="0">
						</a>
					<?php } 
						if($id_preview/*$order_view > $min_position AND isset($rows[$i-1])*/){
					?>
						<a href="<?php echo site_url('admin/pcategory/change_order/' . $id.'/'.$id_preview)?>">
							<img src="<?php echo base_url()?>images/admin/up.gif" alt="Down" title="Down" border="0">
						</a>
					<?php } ?>
					</td>
					<td class="product center" onclick="document.location = '#'">
						<a href="#"><img src="<?php echo base_url( "images/" . $active)?>" width="16" height="16" /></a>
					</td>
					<td class="product center">
						<a href="<?php echo $this->base_url?>admin/pcategory/view/<?php echo $parent?>">
							<img src="<?php echo $this->base_url?>images/admin/details.gif" alt="View" title="View" border="0">
						</a>
						<a href="<?php echo site_url('admin/pcategory/edit/'. $id)?>">
							<img src="<?php echo $this->base_url?>images/admin/edit.gif" alt="Edit" title="Edit" border="0">
						</a>
	
						<a href="<?php echo site_url('admin/pcategory/delete/'. $id)?>" onclick="return confirm('Delete item #<?php echo $id?>?');">
						<img src="<?php echo $this->base_url?>images/admin/delete.gif" alt="Delete" title="Delete" border="0">
						</a>
					</td>
				</tr>
				<?php
				}
				?>
					
				</tbody>
			</table>
			<p class="red">
				<strong><?php echo lang('warning_delete_pcategory');?></strong>
			</p>
			<p>
			<input class="button" name="submitDelcategory" value="Delete selection" onclick="return confirm('Delete selected items?');" type="submit">
			</p>
			<p align="center">
			<?php echo $this->pagination->create_links();?>
			</p>
            <?php
        }else echo lang('not_found_item');
            ?>
		</form>
</div>